/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ResolucionView.java
 *
 * Created on 25-may-2012, 1:20:42
 */
package educar.abmResolucion;

import java.awt.event.ActionListener;
import java.awt.event.MouseListener;
import java.awt.event.WindowListener;
import javax.swing.JButton;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Flubber
 */
public class ResolucionView extends javax.swing.JFrame {

// <editor-fold defaultstate="collapsed" desc="Constructor">
    /** Creates new form ResolucionView */
    public ResolucionView() {
        initComponents();
    }
    // </editor-fold>
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jlTitulo = new javax.swing.JLabel();
        jbAgregar = new javax.swing.JButton();
        jbCancelar = new javax.swing.JButton();
        jScrollPane = new javax.swing.JScrollPane();
        jtResolucion = new javax.swing.JTable();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jlTitulo.setFont(new java.awt.Font("Tahoma", 1, 18));
        jlTitulo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jlTitulo.setText("Administrar Resoluciones");

        jbAgregar.setText("Agregar");

        jbCancelar.setText("Cancelar");

        jtResolucion.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "", "Nro del Alumno", "Codigo de la Actividad", "Solucion", "Nota", "DNI Profesor"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Boolean.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                true, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane.setViewportView(jtResolucion);
        jtResolucion.getColumnModel().getColumn(0).setResizable(false);
        jtResolucion.getColumnModel().getColumn(0).setPreferredWidth(15);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jlTitulo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 674, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jbAgregar, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jbCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(444, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 654, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jlTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 202, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jbAgregar, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

//<editor-fold defaultstate="collapsed" desc=" Declaracion de Variables ">     
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane;
    private javax.swing.JButton jbAgregar;
    private javax.swing.JButton jbCancelar;
    private javax.swing.JLabel jlTitulo;
    private javax.swing.JTable jtResolucion;
    // End of variables declaration//GEN-END:variables
//</editor-fold>

    /**
     * <hr>
     * Tabla del Resolucion
     * <hr>
     * @return jtResolucion
     */    
    public JTable getJTResolucion(){
        return this.jtResolucion;
    }

    /**
     * <hr>
     * El modelo de la Tabla de la Resolucion
     * <hr>
     * @return jtResolucion
     */    
    public DefaultTableModel getModeloTabla(){
        return (DefaultTableModel) jtResolucion.getModel();
    }
    
    /**
     * <hr>
     * setModeloTabla: Modifica el modelo de la tabla a partir de un modelo
     * pasado como parametro.
     * <hr>
     * @param tabla modelo que va a tener la tabla
     */
    public void setModeloTabla(DefaultTableModel tabla){
        if (tabla != null){
            this.jtResolucion.setModel(tabla);
        } else {
            jtResolucion.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "", "Nro del Alumno", "Codigo de la Actividad", "Solucion", "Nota", "Profesor"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Boolean.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                true, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        }    
        jtResolucion.getTableHeader().setReorderingAllowed(false);
        jScrollPane.setViewportView(jtResolucion);
        jtResolucion.getColumnModel().getColumn(0).setResizable(false);
        jtResolucion.getColumnModel().getColumn(0).setPreferredWidth(15);
        jtResolucion.getColumnModel().getColumn(1).setPreferredWidth(160);
        jtResolucion.getColumnModel().getColumn(2).setPreferredWidth(160);
        jtResolucion.getColumnModel().getColumn(3).setPreferredWidth(160);
        jtResolucion.getColumnModel().getColumn(4).setPreferredWidth(160);
        jtResolucion.getColumnModel().getColumn(5).setPreferredWidth(160);
    }//Fin del metodo setModeloTabla()
    
    public JButton getJbAgregar() {
        return jbAgregar;
    }

    public JButton getJbCancelar() {
        return jbCancelar;
    }

    /**
     * <hr>
     * Asigna un Listener a los Botones
     * <hr>
     * @param listener
     */    
    public void setActionListener(ActionListener listener) {
        jbAgregar.addActionListener(listener);
        jbCancelar.addActionListener(listener);
    }

    /**
     * <hr>
     * Asigna un Listener al Mouse
     * <hr>
     * @param listener
     */    
    public void setMouseListener(MouseListener listener) {
        jtResolucion.addMouseListener(listener);
    }

    /**
     * <hr>
     * Asigna un Listener a la Ventana
     * <hr>
     * @param listener
     */
    public void setWindowListener(WindowListener listener){
        this.addWindowListener(listener);
    }

}//Fin de la clase ResolucionView
